package com.example.httpsocket.servlet;

import com.example.httpsocket.entity.MyRequest;
import com.example.httpsocket.entity.MyResponse;
import com.example.httpsocket.servlet.parentServlet.MyHttpServlet;

import java.io.OutputStream;
import java.util.HashMap;

/**
 * @author Huangyt
 * @version 1.0
 * @date 2020/8/27 14:41
 */
public class DogServlet extends MyHttpServlet {
    @Override
    public void doGet(MyRequest myRequest, MyResponse myResponse) {
        this.doPost(myRequest, myResponse);
    }

    @Override
    public void doPost(MyRequest myRequest, MyResponse myResponse) {
        System.out.println("成功调用DogServlet!");
        System.out.println("获取请求参数：" + myRequest.getAttribute("username"));
        HashMap<String, Object> hm = new HashMap<>();
        hm.put("username", "huang");
        myResponse.write(200, "OK", "Content-Type:application/json", hm);
    }

    @Override
    public void init() throws Exception {

    }

    @Override
    public void destroy() {

    }
}
